package com.ankur.fareplease;

import android.app.TabActivity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabSpec;

public class FarePleaseActivity extends TabActivity implements
		OnTabChangeListener {
	TabHost tabHost;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tab);

		tabHost = (TabHost) findViewById(android.R.id.tabhost);
		tabHost.setOnTabChangedListener(this);

		TabSpec autoTabSpec = tabHost.newTabSpec("Auto");
		TabSpec taxiTabSpec = tabHost.newTabSpec("taxi");

		autoTabSpec.setIndicator("Auto Fare", getResources().getDrawable(
				R.drawable.auto));
		taxiTabSpec.setIndicator("Taxi Fare", getResources().getDrawable(
				R.drawable.taxi));

		autoTabSpec.setContent(new Intent(this, AutoActivity.class));
		taxiTabSpec.setContent(new Intent(this, TaxiActivity.class));

		tabHost.addTab(autoTabSpec);
		tabHost.addTab(taxiTabSpec);

		for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
			tabHost.getTabWidget().getChildAt(i).setBackgroundColor(
					Color.parseColor("#7392B5"));
		}

		tabHost.getTabWidget().setCurrentTab(0);
		tabHost.getTabWidget().getChildAt(0).setBackgroundColor(
				Color.parseColor("#4E4E9C"));
	}

	public void onTabChanged(String tabId) {
		for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
			tabHost.getTabWidget().getChildAt(i).setBackgroundColor(
					Color.parseColor("#7392B5"));
		}

		tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab())
				.setBackgroundColor(Color.parseColor("#4E4E9C"));
	}
}